<template>
  <a-modal
    title="新增角色"
    :width="640"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel"
  >
    <a-spin :spinning="confirmLoading">
      <a-form :form="form" :mdl="mdl">
        <a-input type="text" readonly="readonly" v-model="mdl.roleId" hidden="hidden"/>
        <a-form-item
          label="用户名称"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
        >
          <a-input v-model="mdl.name"/>
        </a-form-item>
        <a-form-item
          label="用户描述"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
        >
          <a-input v-model="mdl.description"/>
        </a-form-item>
        <a-form-item
          label="所属单位"
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
        >
          <select name="roleunit" id="roleunit" v-model="mdl.roleunit">
            <option v-for="(item) in jg" :value="item.id" :key="item.id" >{{ item.name }}</option>
          </select>
        </a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
export default {
  data () {
    return {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 7 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 13 }
      },
      mdl: {
        roleId: '',
        name: '',
        description: '',
        roleunit: ''
      },
      jg: {},
      visible: false,
      confirmLoading: false,

      form: this.$form.createForm(this)
    }
  },
  methods: {
    edit (record) {
      this.visible = true
    },
    handleSubmit () {
      this.confirmLoading = true
      const vm = this.mdl
      console.log(this.mdl)
      setTimeout(() => {
        this.visible = false
        this.confirmLoading = false
        this.$emit('ok1', vm)
      }, 1500)
    },
    handleCancel () {
      this.visible = false
    }
  }
}
</script>
